package com.chj;

import java.util.Arrays;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.bind.annotation.RequestMapping;

@SpringBootApplication
public class KafkaProducerConsumer1AppMain extends SpringBootServletInitializer implements WebApplicationInitializer {

	static Logger log = LoggerFactory.getLogger(KafkaProducerConsumer1AppMain.class);

	public static void main(String[] args) {
		ConfigurableApplicationContext ac = SpringApplication.run(KafkaProducerConsumer1AppMain.class, args);
		String[] beanNames = ac.getBeanDefinitionNames();
		Arrays.sort(beanNames);
		for (String beanName : beanNames) {
			log.debug(beanName);
		}
	}

	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
		return builder.sources(getClass());
	}

	@Controller
	public class RootController {

		@RequestMapping("/")
		public String index(HttpServletRequest request) {
			return "redirect:/swagger-ui.html";
		}

	}
}
